﻿<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<![endif]-->
<link rel="stylesheet" type="text/css" href="__PUBLIC__/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/static/h-ui.admin/css/style.css" />

<!--控制 input框 宽度-->
<style type="text/css"> 
.tabwidth{
	width:30px;
}
textarea{ 
	resize:none; 
	width:400px; 
	height:100px;
}
</style>
<title></title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span>  耗材管理<span class="c-gray en">&gt;</span> 耗材一览<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
	<div class="page-container">

		<!--隐藏的耗材展示框-->
		<div class="" style="display:none;">;
			<image src="__PUBLIC__/image/test.jpg" style="width:300px;">
		</div>
		<!--end隐藏的耗材展示框-->
		<div class="mt-20">
			<h2 class="text-c">耗材库存一览</h2>		
			<table class="table table-border table-bordered table-hover table-bg table-sort" style="margin-top: 20px;">
				<thead>
					<tr class="text-c">
						<th width="10%">耗材名称</th>
						<!--遍历耗材名称-->
						<volist name="goodsList" id="vo">
							<th width="30">{$vo.goodsname}</th>	
						</volist>
						<!-- end-->
						<th width="10%">总计</th>
					</tr>
				</thead>

				<tbody>
					<tr class="text-c">
						<td width="10%">当前状态</td>
						<!--遍历耗材是否上架-->
						<volist name="goodsList" id="vo">
							<td>
								<if condition="$vo.status eq 1 ">
									<button class="label label-success butt" onClick="sold_out(this,'{$vo.gid}')">上架</button>
								<else />
									<button class="label label-danger butt" onClick="putaway(this,'{$vo.gid}')">下架</button>
								</if>
							</td>
						</volist>
						<!--end遍历耗材是否上架-->
						<td></td>
					</tr>
					<tr class="text-c">
						<td width="10%">单价</td>
						<!--遍历耗材价格-->
						<volist name="goodsList" id="vo">
							<td>{$vo.price}</td>
						</volist>
						<!--end遍历耗材价格-->
						<td></td>
					</tr>
					<tr class="text-c">
						<td>库存数量</td>
						<!--遍历耗材价格-->
						<volist name="goodsList" id="vo">
							<input type="hidden" name="gid[]" value="{$vo.gid}">
							<td>{$vo.amount}</td>
						</volist>
						<!--end遍历耗材价格-->
						<td></td>
					</tr>					
					<tr class="text-c">
						<td>小计</td>
						<!--遍历耗材价格-->
						<volist name="goodsList" id="vo">
							<td>{$vo.total}</td>
						</volist>
						<!--end遍历耗材价格-->
						<td>{$total}</td>
					</tr>
				</tbody>	
			</table>
		</div>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="__PUBLIC__/lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="__PUBLIC__/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="__PUBLIC__/static/h-ui/js/H-ui.min.js"></script> 
<script type="text/javascript" src="__PUBLIC__/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
	/*耗材下架*/
	function sold_out(obj,gid) {
		layer.confirm('确认要下架吗？',function(index){
				$.ajax({
				type: 'POST',
				url: '__CONTROLLER__/sold_out',
				data:{"gid":gid},
				dataType: 'json',
				success: function(data){
					$(obj).replaceWith('<button class="label label-danger butt" onClick="putaway(this,'+'{$vo.gid}'+')">下架</button>');
					/*$(obj).addClass('label-danger');
					$(obj).removeClass('label-success');*/
					$(obj).remove();
					layer.msg('已下架!',{icon: 6,time:1000});
				},
				error:function(data) {
					console.log(data.msg);
				},
			});		
		});
	}	

	/*耗材上架*/
	function putaway(obj,gid) {
		layer.confirm('确认要上架吗？',function(index){
				$.ajax({
				type: 'POST',
				url: '__CONTROLLER__/putaway',
				data:{"gid":gid},
				dataType: 'json',
				success: function(data){
					$(obj).replaceWith('<button class="label label-success butt" onClick="sold_out(this,'+'{$vo.gid}'+')">上架</button>');
					$(obj).remove();
					layer.msg('已上架!',{icon: 6,time:1000});
				},
				error:function(data) {
					console.log(data.msg);
				},
			});		
		});
	}
</script>
</body>
</html>